//
//  NewFeatureController.m
//  OC-微博
//
//  Created by Apple on 15/11/10.
//  Copyright © 2015年 Apple. All rights reserved.
//

#import "NewFeatureController.h"
#import "NewFeatureCell.h"
@interface NewFeatureController ()
@property (nonatomic, strong) NewFeatureCell *newcell;
@end

@implementation NewFeatureController

static NSString * const NewFeatureControllerID = @"Cell";

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.collectionView registerClass:[NewFeatureCell class] forCellWithReuseIdentifier:NewFeatureControllerID];
    
    // Do any additional setup after loading the view.
}


#pragma mark /*******************  数据源方法  *******************/
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    NewFeatureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NewFeatureControllerID forIndexPath:indexPath];
    
    //cell.backgroundColor = (indexPath.item % 2 == 0 )? [UIColor redColor]:[UIColor yellowColor] ;
    cell.imageIndex = indexPath.item;
    self.newcell = cell;
    return cell;
}
#pragma mark /*******************  停止滚动  *******************/
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
//1.计算当前页数
    NSInteger page = scrollView.contentOffset.x / scrollView.bounds.size.width;
    if (page !=3 ) {
        return;
    }
    
    //[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:page inSection:0]];
    [self.newcell showButtonAnim];
}
#pragma mark /*******************  构造函数  *******************/
- (instancetype)init {
   
    UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
    layout.itemSize = [UIScreen mainScreen].bounds.size;
    layout.minimumInteritemSpacing = 0;
    layout.minimumLineSpacing = 0;
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
     NewFeatureController *newVC = [[NewFeatureController alloc]initWithCollectionViewLayout:layout];
    newVC.collectionView.pagingEnabled = YES;
    newVC.collectionView.bounces = NO;
    newVC.collectionView.showsHorizontalScrollIndicator = NO;
    return newVC;
}
#pragma mark /*******************  隐藏状态栏  *******************/

@end
